package com.yf1706.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.yf1706.bean.Applicant;
import com.yf1706.bean.CheckCalendarAffair;
import com.yf1706.bean.RecTemplate;
import com.yf1706.dao.jpa.IApplicantJDAO;
import com.yf1706.dao.jpa.INoticeInterviewStatusSettingJDAO;
import com.yf1706.dao.jpa.IRecTemplateJDAO;
import com.yf1706.dao.jpa.IRecWaySettingJDAO;
import com.yf1706.dao.mybatis.IApplicantMDAO;
import com.yf1706.dao.mybatis.IRecTemplateMDAO;
import com.yf1706.vo.ApplicantVO;
import com.yf1706.vo.CheckCalendarAffairVO;

@Service
@Transactional(rollbackFor=Exception.class)
public class ApplicantService {
	@Autowired
	private IApplicantMDAO amdao;
	@Autowired
	private IApplicantJDAO ajdao;
	@Autowired
	private INoticeInterviewStatusSettingJDAO nissjdao;
	@Autowired
	private IRecWaySettingJDAO rwsjdao;
	
	//一、查询所有
	public List<Applicant> queryAllApplicant(){
		return amdao.queryAllApplicant();
	}
	
	//二、模糊查询
	public List<Applicant> getSearchAppRegister(String searchValue){
		return amdao.querySearchAppRegister(searchValue);
	}
	
	//三、新增(连表的新增)
	public void addAppRegister(ApplicantVO avo) {
		Applicant a=new Applicant();
		System.out.println(avo);
		a.setApplicantId(avo.getApplicantId());
		a.setApplyDep(avo.getApplyDep());
		a.setApplyPost(avo.getApplyPost());
		a.setEvaluateScore(avo.getEvaluateScore());
		a.setName(avo.getName());
		a.setNoticeInterviewStatusSetting(nissjdao.findByNoticeInterviewStatusId(avo.getNoticeInterviewStatusId()));
		a.setRecPlan(avo.getRecPlan());
		a.setRecWaySetting(rwsjdao.findByRecWayId(avo.getRecWayId()));
		a.setTel(avo.getTel());
		ajdao.save(a);
	}
	
	//四、修改
	public void updateAppRegister(ApplicantVO avo) {
		Applicant a=new Applicant();
		System.out.println(avo);
		a.setApplicantId(avo.getApplicantId());
		a.setApplyDep(avo.getApplyDep());
		a.setApplyPost(avo.getApplyPost());
		a.setEvaluateScore(avo.getEvaluateScore());
		a.setName(avo.getName());
		a.setNoticeInterviewStatusSetting(nissjdao.findByNoticeInterviewStatusId(avo.getNoticeInterviewStatusId()));
		a.setRecPlan(avo.getRecPlan());
		a.setRecWaySetting(rwsjdao.findByRecWayId(avo.getRecWayId()));
		a.setTel(avo.getTel());
		ajdao.save(a);
	}
	
	//五、删除方法
	public void deleteAppRegister(int id) {
		ajdao.deleteById(id);
	}

}
